﻿
Imports elpmis
Imports webctrl

Namespace lpmsservFunctions

    'parameters, page, var, xhtmlpage instance
    '            inlineScript, var, inlineScript instance
    '            i, any, convert to string, the input string
    'return, string, action link
    Public Class jsnumbercheck
        Inherits internalFunction

        Public Class parameters
            Public Const page As String = "page"
            Public Const inlineScript As String = "inlineScript"
            Public Const i As String = "i"
        End Class

        Public Sub New()
            MyBase.New("js.numbercheck")
        End Sub

        Protected Overrides Function invoke(ByVal ctx As context, ByRef output As bare_variable) As Boolean
            Dim i As String = Nothing
            If ctx.findVariableStr(parameters.i, i) Then
                Dim inlineScript As inlineScript = Nothing
                getinlinescript(ctx, inlineScript, parameters.page, parameters.inlineScript)
                output = New bare_variable(typeDefination.string, _
                                           numbercheck.invoke(inlineScript, i))
                Return True
            Else
                raiseError("expect parameter " + parameters.i, errorHandle.errorType.user)
                Return False
            End If
        End Function
    End Class

    'parameters, page, var, xhtmlpage instance
    '            inlineScript, var, inlineScript instance
    '            i, any, convert to string, the input string
    '            cb, any, convert to string, the call back function
    'return, string, action link
    Public Class jsnumberreplace2
        Inherits internalFunction

        Public Class parameters
            Public Const page As String = "page"
            Public Const inlineScript As String = "inlineScript"
            Public Const i As String = "i"
            Public Const cb As String = "cb"
        End Class

        Public Sub New()
            MyBase.New("js.numberreplace2")
        End Sub

        Protected Overrides Function invoke(ByVal ctx As context, ByRef output As bare_variable) As Boolean
            Dim i As String = Nothing
            If ctx.findVariableStr(parameters.i, i) Then
                Dim cb As String = Nothing
                If ctx.findVariableStr(parameters.cb, cb) Then
                    Dim inlineScript As inlineScript = Nothing
                    getinlinescript(ctx, inlineScript, parameters.page, parameters.inlineScript)
                    output = New bare_variable(typeDefination.string, _
                                               numberreplace2.invoke(inlineScript, i, cb))
                    Return True
                Else
                    raiseError("expect parameter " + parameters.cb, errorHandle.errorType.user)
                    Return False
                End If
            Else
                raiseError("expect parameter " + parameters.i, errorHandle.errorType.user)
                Return False
            End If
        End Function
    End Class
End Namespace